<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<%@ include file="/commons/basejs.jsp"%>
<!DOCTYPE html>
<html>
<head>

<title>用户登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body class="login-bg">

	<div class="login">
		<div class="message">DREAM后台登录系统</div>
		<div id="darkbannerwrap"></div>

		<form method="post" action="" class="layui-form">
			<input type="hidden" name="${_csrf.parameterName}"
				value="${_csrf.token}" /> <input name="username"
				lay-verify="username" placeholder="用户名" autocomplete="off"
				type="text" class="layui-input" />
			<hr class="hr15">
			<input name="password" lay-verify="password" placeholder="密码"
				autocomplete="off" type="password" class="layui-input" />
			<hr class="hr15">
			<!-- <div  class="layui-inline">
            <label class="layui-form-label" style="width:40px;padding: 9px 0px;">验证码:</label>
               <div class="layui-input-inline">
                     <input type="text" name="code" style="width:150px;height:35px;" autocomplete="off" lay-verify="code"   class="layui-input">
              </div>
            <div class="layui-input-inline">
                <img src="" id="code">
            </div>
        </div> -->
			<!--   <div>
        <label class="layui-form-label" style="width:40px;padding: 9px 0px;">记住我</label> 
            <input type="checkbox"   name="rememberMe" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
        </div>
        <hr class="hr15"> -->
			<button type="reset" class="layui-btn layui-btn-danger btn-reset"
				style="width:48%;">重置</button>
			<button class="layui-btn btn-submit" lay-submit lay-filter="save"
				style="width:48%;">登陆</button>
			<hr class="hr20">
		</form>
	</div>



	<script type="text/javascript">
		layui.use([ 'form', 'layer' ], function() {
			// 定义操作操作对象
			var form = layui.form, layer = layui.layer, $ = layui.jquery;
			// 提示弹出验证框
			form.verify({
				username : function(value) {
					if (value.trim() == "") {
						return "请输入用户名";
					}
				},
				password : function(value) {
					if (value.trim() == "") {
						return "请输入密码";
					}
				},
			//占时没有验证码
			/*  
			 code: function (value) {
			     if (value == "") {
			         return "请输入验证码";
			     }
			 } 
			 */
			});

			// 提交监听
			form.on('submit(save)', function(data) {
				$.ajax({
					type : 'POST',
					url : basePath + '/login',
					dataType : 'json',
					data : data.field,//往后台发送的是data.field，即一个{name：value}的数据结构
					async : true,
					success : function(result) {
						if (result.success) {
							window.location.href = basePath + '/index';
						} else {
							layer.msg(result.msg, {
								icon : 5,//图标
								anim : 6//抖动
							});
						}
					}
				});
				return false;
			});
		});
		if (window != top) {
			top.location.href = location.href;//保持在最上层
			}
	</script>
</body>
</html>
